package com.palm.hubo2o.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.palm.hubo2o.R;
import com.palm.hubo2o.model.IssuePrize;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by dest1 on 2015/10/13.
 */
public class PrizeDetailAdapter extends RecyclerView.Adapter<PrizeDetailAdapter.DetailHolder> {
    private List<IssuePrize.PrizeLevel> pools;

    public PrizeDetailAdapter(List<IssuePrize.PrizeLevel> pools) {
        super();
        this.pools = pools;
    }

    @Override
    public DetailHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_prize_detail, parent, false);
        return new DetailHolder(v);
    }

    @Override
    public void onBindViewHolder(DetailHolder holder, int position) {
        holder.award.setText(pools.get(position).getName());
        holder.note.setText(String.valueOf(pools.get(position).getCount()));
        holder.money.setText(pools.get(position).getMoney());
    }

    @Override
    public int getItemCount() {
        return pools.size();
    }

    class DetailHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.award_item_prize)
        TextView award;
        @Bind(R.id.note_item_prize)
        TextView note;
        @Bind(R.id.money_item_prize)
        TextView money;

        public DetailHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
